import java.util.HashSet;
import java.util.Set;

public class MLS {
    public int MLS (int[] arr) {
        // write code here
        Set<Integer> hash = new HashSet<>();
        for (int n : arr) {
            if (!hash.contains(n)) {
                hash.add(n);
            }
        }
        int ret = 1;
        for (int n : arr) {
            if (!hash.contains(n-1)) {
                int len = 1;
                while (hash.contains(++n)) {
                    len++;
                }
                ret = Math.max(ret, len);
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        int[] arr = {100,4,200,1,3,2};
        MLS mls = new MLS();
        System.out.println(mls.MLS(arr));
    }
}
